import { CopyInfoPanelBase } from "../copy/CopyInfoPanelBase";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { ClockManager } from "../../manager/ClockManager";
import { EventName } from "../../mvc/EventName";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { DataEvent } from "../../events/DataEvent";
import { SCrossBossJoin } from "../../../../Message/Public/SCrossBossJoin";
import { SecTimerView } from "../common/SecTimerView";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class CrossBossIntrPanel
    
    export  class CrossBossIntrPanel extends CopyInfoPanelBase
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super(arg1);
            this.title = Language.getString(60720);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            super.createChildren();
            loc1 = GlobalStyle.setTextFormatLeading(GlobalStyle.textFormat6, 5);
            loc1.color = 16711680;
            this._tip1 = ObjCreate.createGTextField(Language.getString(60724), _left, 40, 240, 20, _bodySp, loc1);
            this._tip1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tip1.wordWrap = true;
            this._tip1.mouseEnabled = false;
            loc1.color = GlobalStyle.color1Uint;
            this._condition = ObjCreate.createGTextField("", _left, this._tip1.y + this._tip1.textHeight + 20, 240, 20, _bodySp, loc1);
            this._condition.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._condition.htmlText = Language.getStringByParam(60725, "", "", "");
            this._condition.wordWrap = true;
            this._condition.mouseEnabled = false;
            return;
        }

        public updateCountDownTimer(arg1: Date): void
        {
            this._leftTime = (arg1.time - ClockManager.instance.nowDate.time) / 1000;
            if (!this._countDown) 
            {
                this._countDown = ObjCreate.createSecTimeView("", _left, 10, 240, 20, _bodySp, GlobalStyle.textFormat6);
                this._countDown.addEventListener(EventName.SecViewTimeChange, this.onSecTimeChange);
                this._countDown.filters = [FilterConst.glowFilter];
            }
            this.updateCountDownView();
            return;
        }

        /* internal  */updateCountDownView(): void
        {
            if (this._leftTime <= 0) 
            {
                this._countDown.stop();
                this._countDown.setParse("");
                this._countDown.htmlText = Language.getString(60723);
            }
            else if (this._leftTime <= 120) 
            {
                this._countDown.setParse(HTMLUtil.addColor(Language.getString(60722), "#FFFF00"));
                this._countDown.setLeftTime(this._leftTime);
            }
            else 
            {
                this._countDown.setParse(HTMLUtil.addColor(Language.getString(60721), "#FFFF00"));
                this._countDown.setLeftTime(this._leftTime - 120);
            }
            return;
        }

        /* internal  */onSecTimeChange(arg1: DataEvent): void
        {
            var loc1=arg1.data as int;
            if (loc1 <= 0) 
            {
                this.updateCountDownView();
            }
            else 
            {
                --this._leftTime;
            }
            return;
        }

        public updateJoinInfo(arg1: SCrossBossJoin): void
        {
            var loc1=arg1 ? arg1.playerNum : 0;
            var loc2=arg1 ? arg1.combat : 0;
            var loc3="";
            var loc4="";
            var loc5="";
            var loc6=false;
            var loc7=false;
            if (loc1 >= this.PlayerNum) 
            {
                loc6 = true;
                loc4 = HTMLUtil.addColor(Language.getString(60730), GlobalStyle.color5);
            }
            else 
            {
                loc4 = HTMLUtil.addColor(Language.getStringByParam(60728, loc1), GlobalStyle.color7);
            }
            if (loc2 >= this.Combat) 
            {
                loc7 = true;
                loc5 = HTMLUtil.addColor(Language.getString(60730), GlobalStyle.color5);
            }
            else 
            {
                loc5 = HTMLUtil.addColor(Language.getStringByParam(60729, loc2), GlobalStyle.color7);
            }
            if (loc6 && loc7) 
            {
                loc3 = HTMLUtil.addColor(Language.getString(60727), GlobalStyle.color5);
            }
            else 
            {
                loc3 = HTMLUtil.addColor(Language.getString(60726), GlobalStyle.color7);
            }
            this._condition.htmlText = Language.getStringByParam(60725, loc3, loc4, loc5);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this._countDown.removeEventListener(EventName.SecViewTimeChange, this.onSecTimeChange);
            this._countDown.dispose();
            this._countDown = null;
            return;
        }

        /* internal */ /* const */PlayerNum: int=5;

        /* internal */ /* const */Combat: int=150000;

        /* internal */ /* var */_countDown: SecTimerView;

        /* internal */ /* var */_tip1: GTextFiled;

        /* internal */ /* var */_condition: GTextFiled;

        /* internal */ /* var */_leftTime: int=0;
    }
